package com.huawei.updatesdk.service.otaupdate;

import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.Log;
import com.huawei.updatesdk.service.e.c;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class g {
    private static g a = new g();
    private String b;
    private String c;
    private String d = null;

    static class a extends AsyncTask<Void, Void, String> {
        private a() {
        }

        /* JADX WARNING: inconsistent code. */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        protected java.lang.String a(java.lang.Void... r9) {
            /*
            r8 = this;
            r6 = 0;
            r0 = "content://com.huawei.appmarket.commondata/item/1";
            r1 = android.net.Uri.parse(r0);
            r0 = com.huawei.updatesdk.a.b.a.a.a();	 Catch:{ Exception -> 0x004d }
            r0 = r0.b();	 Catch:{ Exception -> 0x004d }
            r0 = r0.getContentResolver();	 Catch:{ Exception -> 0x004d }
            r2 = 0;
            r3 = 0;
            r4 = 0;
            r5 = 0;
            r2 = r0.query(r1, r2, r3, r4, r5);	 Catch:{ Exception -> 0x004d }
            if (r2 == 0) goto L_0x003b;
        L_0x001d:
            r0 = r2.moveToFirst();	 Catch:{ Exception -> 0x008e, all -> 0x008b }
            if (r0 == 0) goto L_0x003b;
        L_0x0023:
            r0 = "homecountry";
            r0 = r2.getColumnIndex(r0);	 Catch:{ Exception -> 0x008e, all -> 0x008b }
            r1 = r2.getString(r0);	 Catch:{ Exception -> 0x008e, all -> 0x008b }
            r0 = com.huawei.updatesdk.service.otaupdate.g.a();	 Catch:{ Exception -> 0x0093, all -> 0x008b }
            r0.b(r1);	 Catch:{ Exception -> 0x0093, all -> 0x008b }
            r0 = r1;
        L_0x0035:
            if (r2 == 0) goto L_0x003a;
        L_0x0037:
            r2.close();	 Catch:{ Exception -> 0x0044 }
        L_0x003a:
            return r0;
        L_0x003b:
            r0 = "ServiceZoneUtil";
            r1 = "cursor == null: ";
            android.util.Log.e(r0, r1);	 Catch:{ Exception -> 0x008e, all -> 0x008b }
            r0 = r6;
            goto L_0x0035;
        L_0x0044:
            r1 = move-exception;
            r1 = "ServiceZoneUtil";
            r2 = "cursor Execption";
            com.huawei.updatesdk.a.a.b.a.a.a.d(r1, r2);
            goto L_0x003a;
        L_0x004d:
            r0 = move-exception;
            r1 = r0;
            r0 = r6;
        L_0x0050:
            r2 = "ServiceZoneUtil";
            r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x007b }
            r3.<init>();	 Catch:{ all -> 0x007b }
            r4 = "close cursor error: ";
            r3 = r3.append(r4);	 Catch:{ all -> 0x007b }
            r1 = r1.toString();	 Catch:{ all -> 0x007b }
            r1 = r3.append(r1);	 Catch:{ all -> 0x007b }
            r1 = r1.toString();	 Catch:{ all -> 0x007b }
            android.util.Log.e(r2, r1);	 Catch:{ all -> 0x007b }
            if (r6 == 0) goto L_0x003a;
        L_0x006e:
            r6.close();	 Catch:{ Exception -> 0x0072 }
            goto L_0x003a;
        L_0x0072:
            r1 = move-exception;
            r1 = "ServiceZoneUtil";
            r2 = "cursor Execption";
            com.huawei.updatesdk.a.a.b.a.a.a.d(r1, r2);
            goto L_0x003a;
        L_0x007b:
            r0 = move-exception;
        L_0x007c:
            if (r6 == 0) goto L_0x0081;
        L_0x007e:
            r6.close();	 Catch:{ Exception -> 0x0082 }
        L_0x0081:
            throw r0;
        L_0x0082:
            r1 = move-exception;
            r1 = "ServiceZoneUtil";
            r2 = "cursor Execption";
            com.huawei.updatesdk.a.a.b.a.a.a.d(r1, r2);
            goto L_0x0081;
        L_0x008b:
            r0 = move-exception;
            r6 = r2;
            goto L_0x007c;
        L_0x008e:
            r0 = move-exception;
            r1 = r0;
            r0 = r6;
            r6 = r2;
            goto L_0x0050;
        L_0x0093:
            r0 = move-exception;
            r6 = r2;
            r7 = r1;
            r1 = r0;
            r0 = r7;
            goto L_0x0050;
            */
            throw new UnsupportedOperationException("Method not decompiled: com.huawei.updatesdk.service.otaupdate.g.a.a(java.lang.Void[]):java.lang.String");
        }

        protected /* synthetic */ Object doInBackground(Object[] objArr) {
            return a((Void[]) objArr);
        }
    }

    private g() {
    }

    public static g a() {
        return a;
    }

    public void a(Context context) {
        this.c = null;
        if (c.b(context)) {
            a aVar = new a();
            aVar.executeOnExecutor(Executors.newSingleThreadExecutor(), new Void[0]);
            try {
                aVar.get(1000, TimeUnit.MILLISECONDS);
            } catch (Exception e) {
                aVar.cancel(true);
                Log.e("ServiceZoneUtil", "init AccountZone error: " + e.toString());
            }
        }
    }

    public void a(String str) {
        this.b = str;
    }

    public String b() {
        return this.b;
    }

    public void b(String str) {
        this.c = str;
    }

    public String c() {
        return this.d;
    }

    public void c(String str) {
        this.d = str;
    }

    public String d() {
        return !TextUtils.isEmpty(this.b) ? this.b : this.c;
    }
}
